package app

import (
	xtime "ucenter/utils"
)

var Conf *AppConf

type AppConf struct {
	Listen      string      `yaml:"listen"`
	LogConf     string      `yaml:"logConf"`
	LandingPage string      `yaml:"landingPage"`
	OauthConf   *HttpClient `yaml:"oauthClient,omitempty"`
	PayConf     *HttpClient `yaml:"payClient,omitempty"`
	UUIDConf    *HttpClient `yaml:"uuidConf,omitempty"`
	RummyNode   string      `yaml:"rummyNode"`
	Mysql       *Mysql      `yaml:"mysql"`
	Redis       *Redis      `yaml:"redis"`
	LoginRedis  *Redis      `yaml:"login_redis"`
}

type HttpClient struct {
	Host            string         `yaml:"host"`
	URL             string         `yaml:"url"`
	MaxIdleConn     int            `yaml:"maxIdleConn"`
	MaxConnPerHost  int            `yaml:"maxConn"`
	IdleConnTimeout xtime.Duration `yaml:"idleConnTimeout"`
	Timeout         xtime.Duration `yaml:"timeout"`
}

type Mysql struct {
	Debug          bool   `yaml:"debug"`
	DSN            string `yaml:"dsn,omitempty"`
	IdleConnection int    `yaml:"maxIdleConnection,omitempty"`
	MaxConnection  int    `yaml:"maxConnection,omitempty"`
}

type Redis struct {
	Network      string         `yaml:"netWork,omitempty"`
	Addr         string         `yaml:"addr,omitempty"`
	Auth         string         `yaml:"auth,omitempty"`
	Database     int            `yaml:"database,omitempty"`
	Active       int            `yaml:"active,omitempty"`
	Idle         int            `yaml:"idle,omitempty"`
	DialTimeout  xtime.Duration `yaml:"dialTimeout,omitempty"`
	ReadTimeout  xtime.Duration `yaml:"readTimeout,omitempty"`
	WriteTimeout xtime.Duration `yaml:"writeTimeout,omitempty"`
	IdleTimeout  xtime.Duration `yaml:"idleTimeout,omitempty"`
}
